﻿<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title></title>
	<meta charset="utf-8" />
	<link href="../lib/highlight/default.css" rel="stylesheet" />
	<script src="../lib/highlight.js"></script>
	<script src="../lib/Coro.js"></script>
	<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>


	<h1>Output：</h1>
	<div id="console" style="border:1px solid #ddd; padding:20px; border-radius:20px;"></div>
	<script>
		var console = {
			log : function(msg){
				var div = document.createElement("div");
				div.innerText = msg;
				document.getElementById("console").appendChild(div);
			}
		}
	</script>

	<script>
var fun1 = function(){
	return coro.run(function*(){
		console.log("fun1:11111");
		yield;
		yield new Promise((resolve)=>{
			setTimeout(()=>{ console.log("fun1:22222"); resolve(); }, 1000)
		});

		return "result:fun1";
	});
};

var fun2 = ()=>{
	return coro.run(function*(){
		console.log("fun2:11111");
		yield;

		console.log(yield fun1());

		console.log("fun2:22222");
		yield;

		return "result:fun2"
	});
};

fun2().then(val=>{
	console.log(val);
});
	</script>


	<h1>Script：</h1>
<pre><code class="javascript">
var fun1 = function(){
	return coro.run(function*(){
		console.log("fun1:11111");
		yield;
		yield new Promise((resolve)=>{
			setTimeout(()=>{ console.log("fun1:22222"); resolve(); }, 1000)
		});

		return "result:fun1";
	});
};

var fun2 = ()=>{
	return coro.run(function*(){
		console.log("fun2:11111");
		yield;

		console.log(yield fun1());

		console.log("fun2:22222");
		yield;

		return "result:fun2"
	});
};

fun2().then(val=>{
	console.log(val);
});
</code></pre>

	


</body>
</html>
